'use strict';

const Controller = require('egg').Controller;

class NewController extends Controller {
  async index() {
    const { ctx } = this;
    // console.log(ctx.request.query);
    const {limit,skip}=ctx.request.query
    var db = this.app.mongodb;
    var res = await db.collection("IndexNew").find().skip(Number(skip)).limit(Number(limit)).toArray();
    if (res.length) {
      ctx.body = {
        status: 200,
        res,
        total:res.length
      }
    } else {
      ctx.status = 400;
      ctx.body = {
        status: 400,
        msg: "输入参数不合法"
      }
    }
  }
}

module.exports = NewController;
